package vo;

import service.ICartLineService;
import service.ICartService;
import service.Impl.ICartLineServiceImpl;
import service.Impl.ICartServiceImpl;

import java.util.List;

public class Cart {
    private ICartLineService cartService = new ICartLineServiceImpl();

    private int id;
    private int userId;
    private double totalPrice;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public int getTotal(){
        List<CartLine> cartLines = cartService.selectCartLineByCartId(id);
        int total = 0;
        for(CartLine cartLine : cartLines) {
            total += cartLine.getQuanlity();
        }
        return total;
    }

    public Cart() {
    }
}
